<template>
    <article class="business">
        <aside>
            <div>陕西宏迪汽车服务有限公司</div>
            <ul>
                <li>
                    <p>合作热线</p>
                    <p>13109625221</p>
                </li>
            </ul>
        </aside>
        <ul class="busForm">
            <li>
                <p>企业名称</p>
                <input type="text" v-model="business.companyName" placeholder="请输入企业或商铺名称" />
            </li>
            <li>
                <p>联系人</p>
                <input type="text" v-model="business.contactPerson" placeholder="请输入联系人" />
            </li>
            <li>
                <p>企业电话</p>
                <input type="text" v-model="business.mobile" placeholder="请输入联系电话" />
            </li>
        </ul>
        <div class="busSubmit">
            <button @click="applicationSubmit">
                上述信息确认无误，提交申请<img src="../images/yes.png" alt="" />
            </button>
        </div>
    </article>
</template>

<script>
    import Request from "@/api/baseRequest.js";
    import { mixin_Coupon } from "@/mixins/coupon.js";
    export default {
        name: "",
        components: {},
        props: {},
        mixins: [mixin_Coupon],
        data() {
            return {
                business: {
                    companyName: "",
                    contactPerson: "",
                    mobile: "",
                    id: "0",
                    createTime: "",
                },
            };
        },
        methods: {
            rules() {
                let { companyName, mobile, contactPerson } = this.business;
                if (!companyName) {
                    this.$Alert({ title: '信息提示', message: '企业或商铺名称不能为空' });
                    return false;
                }
                if (!contactPerson) {
                    this.$Alert({ title: '信息提示', message: '联系人不能为空' });
                    return false;
                }
                if (!mobile) {
                    this.$Alert({ title: '信息提示', message: '电话号码为空，请输入电话号码' });
                    return false;
                }
                if (!/^1[3456789]\d{9}$/.test(mobile)) {
                    this.$Alert({ title: '信息提示', message: '电话号码有误，请重填' });
                    return false;
                }
                return true;
            },
            async applicationSubmit() {
                if (!this.rules()) return false;
                const { code, msg } = await Request.addBusinessContact(this.business);
                if ([200, "200", "OK", 0].includes(code)) {
                    this.back();
                }
                this.$Alert({ title: '信息提示', message: msg });
            },
        },
        watch: {},
    };
</script>

<style lang="less" scoped>
    @import url("@/styles/business.less");
</style>
